<?php 
require_once("includes/common.php");

pr($_FILES);
$_POST['lang'] = implode(',',$_POST['lang']);
$_POST['hobbies'] = implode(',',$_POST['hobbies']);
$_POST['dob'] = date('Y-m-d',strtotime($_POST['dob']));
$_POST['register_date'] = date('Y-m-d h:i:s');
$_POST['status'] = 1;

if($_FILES['image']['error']==0){
  $source = $_FILES['image']['tmp_name'];
  $fileName = date('Ymdhis').'_'.$_FILES['image']['name'];
  $dest = "uploads/$fileName";
  $_POST['image'] = $fileName;
  copy($source, $dest);
  unlink('uploads/'.$_POST['hiddenImage']);
} 
  unset($_POST['hiddenImage']);

//pr($_POST);
////////////////// INSERT INTO DB //////////////
$id = $_POST['id'];

echo $inseredId = update('users',$_POST," WHERE `id`='$id' ");
header("location:layout.php?page=view_profile&id=$id");
/////////////////////////////////////////////////

